/**
 * @Author yinyunqi
 * @date 2018年2月2日
 * @Content 
 */
package com.yongqi.controller.back;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.yongqi.model.Family;
import com.yongqi.service.FamilyService;

@Controller
@RequestMapping("/back/family")
public class BackFamilyController {
    @Autowired
    FamilyService familyService;
    /**
     * 后台家庭用户管理
     * @return 家庭用户管理页面
     */
    @RequestMapping("/index")
    public String backFamilyIndex() {
	return "back/back_family";
    }
    /**
     * 后台-家庭管理-查询
     * @param pageNumber
     * @param pageSize
     * @param familyname
     * @param familyaccount
     * @return
     */
    @ResponseBody
    @RequestMapping("/query")
    public String backFamilyQuery(@RequestParam int pageNumber,int pageSize,String familyname,String familyaccount) {
    	Map<String, String> map = new HashMap<String, String>();
    	map.put("familyname", familyname);
    	map.put("familyaccount", familyaccount);
    	int total = familyService.backFamilyQuery(map).size();
    	PageHelper.startPage(pageNumber, pageSize);
    	List<Family> familyList = familyService.backFamilyQuery(map);
    	JSONObject object = new JSONObject();
    	object.put("rows", familyList);
    	object.put("total", total);
    	return object.toJSONString();
    }
    
    /**
     * 后台-地图-用户分布页面
     */
    @RequestMapping("/distribution")
    public String backFamilyDistribution() {
	return "back/back_family_distribution";
    }
    /**
     * 后台-地图-用户分布数据
     * @return
     */
    @ResponseBody
    @RequestMapping("/distributionData")
    public String backFamilyDistributionData() {
	List<Family> familyList = familyService.backFamilyDistributionData();
	JSONObject object = new JSONObject();
	object.put("address", familyList);
    	return object.toJSONString();
    }
}

